package com.example.dailyrecord.entity;

import com.example.dailyrecord.util.FunctionUtils;
import com.example.dailyrecord.util.IDUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel("系统日志")
public class Log {
    @ApiModelProperty("备注，记录是否有异常")
    private String bz;
    @ApiModelProperty("行为内容")
    private String content;
    @ApiModelProperty("")
    private String id;
    @ApiModelProperty("IP地址")
    private String ip;
    @ApiModelProperty("行为时间")
    private String time;
    @ApiModelProperty("用户id")
    private String uid;
    @ApiModelProperty("请求路径")
    private String uri;
    public static final String TABLE_NAME = "log";
    public static final String[] ALL_COLUMNS = {"`bz`", "`content`", "`id`", "`ip`", "`time`", "`uid`", "`uri`"};
    public static final String BZ_COLUMN = "`bz`";
    public static final String BZ_NAME = "bz";
    public static final String CONTENT_COLUMN = "`content`";
    public static final String CONTENT_NAME = "content";
    public static final String ID_COLUMN = "`id`";
    public static final String ID_NAME = "id";
    public static final String IP_COLUMN = "`ip`";
    public static final String IP_NAME = "ip";
    public static final String TIME_COLUMN = "`time`";
    public static final String TIME_NAME = "time";
    public static final String UID_COLUMN = "`uid`";
    public static final String UID_NAME = "uid";
    public static final String URI_COLUMN = "`uri`";
    public static final String URI_NAME = "uri";

    public static Log getInstance(String email, String content, String uri, String ip, String bz) {
        Log log = new Log();
        log.setId(IDUtils.getStringID());
        log.setTime(FunctionUtils.getNowTime());
        log.setUid(email);
        log.setContent(content);
        log.setUri(uri);
        log.setIp(ip);
        log.setBz(bz);
        return log;
    }
}
